import operator


def Collatz(n):
    result = 1

    while n % 2 == 0:
        result += 1
        n /= 2

    if n == 1:
        return result

    return result + Collatz(3*n + 1)

def Solve():
    limit = 10**6
    result = [0] * limit

    for n in xrange(1, 10**6):
        i, res = n, 1
        while True:
            if i == 1:
                result[n] = res
                break
            if i < n:
                if result[i] != 0:
                    result[n] = result[i] + res
                    break
            if i % 2 == 0:
                i, res = i/2, res + 1
            else:
                i, res = 3*i + 1, res + 1

    index, value = max(enumerate(result), key=operator.itemgetter(1))
    return index


